package cn.agiledata.security.db.service;



import org.apache.commons.beanutils.BeanUtils;

import cn.agiledata.security.db.bean.EnctBean;
import cn.agiledata.security.db.factory.IEnctBeanFactory;

import cn.agiledata.bank.common.util.Constant;
import cn.agiledata.bank.common.util.StringUtil;
import cn.agiledata.bank.hibernateBean.Account;
import cn.agiledata.bank.hibernateBean.AccountBalance;
import cn.agiledata.bank.hibernateBean.Transaction;

public class AvoidJuggleServiceImpl implements IAvoidJuggleService,Constant {
	public ICommonJuggleService commonJuggleService;
	
	public IEnctBeanFactory enctBeanFactory;
	
	
	public void setCommonJuggleService(ICommonJuggleService commonJuggleService) {
		this.commonJuggleService = commonJuggleService;
	}







	public void setEnctBeanFactory(IEnctBeanFactory enctBeanFactory) {
		this.enctBeanFactory = enctBeanFactory;
	}
	


	/**
	 * 构造帐户余额表的加密字段
	 * @return
	 */
	public Object parseEncrCode(Object object) {		
		return commonJuggleService.parseEncrCode(getEncrBean(object));
	}
	

	
	/**
	 * 得到需要加密的bean
	 * @param object
	 * @return
	 */
	public EnctBean getEncrBean(Object object){
		EnctBean bean = null;
		
		if(object instanceof AccountBalance)	{
			bean = enctBeanFactory.getAcctBalEnctBean((AccountBalance)object);
		}
		if(object instanceof Transaction)	{
			bean = enctBeanFactory.getTransactionEnctBean((Transaction)object);
		}
		if(object instanceof Account)	{
			bean = enctBeanFactory.getAccountEnctBean((Account)object);
		}
		return bean;
	}
 }
